'use strict';

angular.module('app')
  .directive('appPositionList', [
    'cache', '$http',
    function(cache, $http) {
      return {
        restrict: 'A',
        replace: true,
        scope: {
          data: "=",
          filterObj: "=",
          isFavorite: "="
        },
        link: function(scope) {
          scope.select = function(item) {
            $http.post('data/myFavorite.json', {
                id: item.id,
                select: item.select
              })
              .then(function(success) {
                item.select = !!item.select;
                console.log(item.select);
              }, function(error) {
                // body...
              });
          }
        },
        templateUrl: 'view/template/positionList.html'
      }
    }
  ])
